package com.ymx.darling.type;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.YearMonth;

public class YearMonthHandler implements TypeHandler<YearMonth> {
    @Override
    public YearMonth getResult(ResultSet resultSet, int columIndex) throws SQLException {
        String value = resultSet.getString(columIndex);
        return value == null ? null : YearMonth.parse(value);
    }

    @Override
    public void setParameter(PreparedStatement statement, YearMonth value, int index) throws SQLException {
        statement.setString(index, value.toString());
    }
}
